package com.itheima.mycollectiondemo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class MyCollectionDemo3 {
    public static void main(String[] args) {
        Collection<String> c =new ArrayList<>();
        c.add("a");
        c.add("b");
        c.add("c");
        c.add("d");
        Iterator<String> iterator = c.iterator();
        //调用iterator方法获取iterator对象,默认指向索引0
        //用while循环,调用hasNext方法判断
        while (iterator.hasNext()){
            //使用next方法取出
            System.out.println(iterator.next());
        }


    }
}
